Skip to content

feat: archive fee - #1124

Open
DyferHerioss wants to merge 6 commits into
preprodfrom
feat/archive-fees-and-credit-movement-ui
Open

feat: archive fee#1124
DyferHerioss wants to merge 6 commits into
preprodfrom
feat/archive-fees-and-credit-movement-ui

Conversation

@DyferHerioss

Copy link
Copy Markdown
Collaborator

No description provided.

} from "react-admin";
import {useToggle} from "../../../hooks";

export const ArchiveWithConfirm: FC<{

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use FC, it's deprecated

Comment on lines +53 to +55
if (redirect) {
doRedirect(redirect);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put it outside the try

} & Omit<ButtonProps, "children">;
} & {"data-testid"?: string} & Omit<ButtonProps, "children">;

export const FileDownloader: FC<FileDownloaderProps> = ({

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, boy scoot patern

import {Informations} from "./profilContent/InformationContent";
import {ProfileCardAvatar} from "./profilContent/ProfilCardAvatar";

export const ProfileLayout: FC<{

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

borderRadius="10px"
position="relative"
>
{/* Cover */}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need

Comment on lines +8 to +94
const sortByCreationDateDesc = (payments: Payment[]): Payment[] =>
[...payments].sort(
(a, b) =>
new Date(b.creation_datetime ?? 0).getTime() -
new Date(a.creation_datetime ?? 0).getTime()
);

const fetchAllCreditPayments = async (): Promise<Payment[]> => {
const resultsByStatus = await Promise.all(
ALL_STATUSES.map((status) =>
payingApi().getCreditPaymentsByStatus(status, 1, FETCH_ALL_PAGE_SIZE)
)
);

return sortByCreationDateDesc(
resultsByStatus.flatMap((result) => result.data)
);
};

type StudentInfo = {student_ref?: string; student_credit?: number};

const findStudentInfoByPayment = async (
payments: Payment[]
): Promise<Map<string, StudentInfo>> => {
const feesResult = await payingApi().getFees(
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
1,
FETCH_ALL_PAGE_SIZE
);
const fees = feesResult.data.data ?? [];
const feeById = new Map(fees.map((fee) => [fee.id, fee]));

const studentIds = [
...new Set(
payments
.map((payment) => feeById.get(payment.fee_id!)?.student_id)
.filter((studentId): studentId is string => !!studentId)
),
];

const credits = await Promise.all(
studentIds.map((studentId) => payingApi().getCreditByStudentId(studentId))
);

const creditByStudentId = new Map(
studentIds.map((studentId, index) => [
studentId,
credits[index].data.amount,
])
);

return new Map(
payments.map((payment) => {
const fee = feeById.get(payment.fee_id!);
return [
payment.id!,
{
student_ref: fee?.student_ref,
student_credit: fee?.student_id
? creditByStudentId.get(fee.student_id)
: undefined,
},
];
})
);
};

const enrichWithStudentInfo = async (
payments: Payment[]
): Promise<(Payment & StudentInfo)[]> => {
if (!payments.length) {
return [];
}

const studentInfoByPaymentId = await findStudentInfoByPayment(payments);

return payments.map((payment) => ({
...payment,
...studentInfoByPaymentId.get(payment.id!),
}));
};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's necessary ?

Comment on lines +24 to +68
const studentCreditProvider: HaDataProviderType = {
getList: async (page, perPage, filter) => {
const studentId = filter.studentId as string;

const result = await payingApi().getCreditTransactionsByStudentId(
studentId,
filter as CreditMovement,
page,
perPage
);

return {
data: result.data.map((transaction) => ({
id: transaction.transaction_id,
transaction_id: transaction.transaction_id,
movement: transaction.movement,
amount: transaction.amount,
date_time: transaction.date_time,
fee: transaction.fee,
credit: transaction.credit,
})),
};
},
getOne: async (studentId) => {
const [creditResult, pendingCreditAmount] = await Promise.all([
payingApi().getCreditByStudentId(studentId),
getPendingCreditAmount(studentId),
]);

const credit = creditResult.data;

return {
...credit,
amount: (credit.amount ?? 0) - pendingCreditAmount,
};
},
saveOrUpdate: () => {
throw new Error("Function not implemented.");
},

delete: () => {
throw new Error("Function not implemented.");
},
};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, use pattern

} from "@mui/icons-material";
import {Box} from "@mui/material";

function ManagerMenu() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use arrow function

Comment thread tsconfig.node.tsbuildinfo

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you push this?

Comment thread tsconfig.tsbuildinfo

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same ?

@Mbomain

Mbomain commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Many empty lines, and your test failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants